using AutoMapper;
using B.S.Data.ERP.API.Applications.DingDanCommands;
using ERP.Domain;
using ERP.infratrctrue;
using ERP.Requst;
using MediatR;

namespace B.S.Data.ERP.API.Applications.DingDanHandlers
{
    public class UpdateDingDanCommandHandler : IRequestHandler<UpdateDingDanCommand, APIRequust<int>>
    {
        private readonly IBaseRepository<DingDan> _dingDanRepository;
        private readonly IMapper _mapper;

        public UpdateDingDanCommandHandler(IBaseRepository<DingDan> dingDanRepository, IMapper mapper)
        {
            _dingDanRepository = dingDanRepository;
            _mapper = mapper;
        }

        public async Task<APIRequust<int>> Handle(UpdateDingDanCommand request, CancellationToken cancellationToken)
        {
  
                 var su=_mapper.Map<DingDan>(request);
                await _dingDanRepository.Update(su);
            return new APIRequust<int>
            {
                Code = RequstCode.成功,
                Msg = RequstCode.成功.ToString()
            };
           
        }
    }
}